<template>
  <div>
    <!-- 失效件查询 -->
    <Card>
      <Form :model="disabledForm" ref="disabledForm" :rules="rules" style="display: block;">
        <Row gutter="40">
          <i-col span="6">
            <FormItem>
              <Input v-model="disabledForm.policyNo" placeholder="保单号" />
            </FormItem>
          </i-col>
          <i-col span="6">
            <FormItem>
              <Cascader change-on-select :data="organiztions" v-model="disabledForm.organiztion" placeholder="业务员机构"
                clearable></Cascader>
            </FormItem>
          </i-col>
          <i-col span="6">
            <FormItem>
              <Input v-model="disabledForm.clerkName" placeholder="业务员姓名" />
            </FormItem>
          </i-col>
          <i-col span="6">
            <FormItem>
              <Input v-model="disabledForm.applicantName" placeholder="投保人姓名" />
            </FormItem>
          </i-col>
        </Row>
        <Row gutter="40">
          <i-col span="6">
            <FormItem>
              <Input v-model="disabledForm.postaladdress" placeholder="联系地址" />
            </FormItem>
          </i-col>
          <i-col span="6">
            <FormItem>
              <DatePicker :editable="false" style="width:100%" v-model="disabledForm.payableDayRange" placeholder="应交日时间段"
                type="daterange"></DatePicker>
            </FormItem>
          </i-col>
          <i-col span="6">
            <FormItem>
              <DatePicker :editable="false" style="width:100%" v-model="disabledForm.disabledDayRange"
                placeholder="失效日时间段" type="daterange"></DatePicker>
            </FormItem>
          </i-col>
          <i-col span="6">
            <Row>
              <i-col span="11">
                <FormItem prop="premiumMin">
                  <Input v-model="disabledForm.premiumMin" placeholder="最低应收保费" type="number"
                    @on-blur="decimalConversion(disabledForm.premiumMin)" />
                </FormItem>
              </i-col>
              <i-col span="2" style="text-align:center;line-height:30px">-</i-col>
              <i-col span="11">
                <FormItem prop="premiumMax">
                  <Input v-model="disabledForm.premiumMax" placeholder="最高应收保费" type="number"
                    @on-blur="decimalConversion2(disabledForm.premiumMax)" />
                </FormItem>
              </i-col>
            </Row>
          </i-col>
        </Row>
        <Row gutter="40">
          <i-col span="6">
            <FormItem>
              <Select v-model="disabledForm.payWay" placeholder="交费方式" @on-change="changePayWay" clearable>
                <Option v-for="item in payWayList" :key="item.key" :value="item.key">{{ item.value }}</Option>
              </Select>
            </FormItem>
          </i-col>
          <i-col span="6">
            <Row>
              <i-col span="11">
                <FormItem>
                  <i-input v-model="disabledForm.disabledDayMin" placeholder="最小失效日">
                    <span slot="append">天</span>
                  </i-input>
                </FormItem>
              </i-col>
              <i-col span="2" style="text-align:center;line-height:30px">-</i-col>
              <i-col span="11">
                <FormItem>
                  <i-input v-model="disabledForm.disabledDayMax" placeholder="最大失效日">
                    <span slot="append">天</span>
                  </i-input>
                </FormItem>
              </i-col>
            </Row>
          </i-col>
        </Row>
        <Row>
          <Button type="primary" @click="handleSubmit()" style="margin-right:20px" :loading="querySubmit">查询</Button>
          <Button @click="handleReset()">重置</Button>
        </Row>
      </Form>
    </Card>
    <!-- 失效件计划提交 -->
    <Card style="margin-top:15px">
      <Div class="supervise">
        <Form :model="disabledPlan" style="display: block;">
          <Row>
            <i-col span="14">
              <Div class="supervise-content">
                <Div class="planTime">计划时间:</Div>
                <Row>
                  <FormItem>
                    <RadioGroup v-model="disabledPlan.planTime" @on-change="PlanTypeChange">
                      <i-col span="12">
                        <Radio label="失效日后">
                          <span style="font-weight:normal">
                            失效日后
                            <Input :disabled="disabledPlan.afterDayDisabled" style="width:60px"
                              v-model="disabledPlan.afterDay" @on-blur="dateValue2" />天
                          </span>
                        </Radio>
                      </i-col>
                      <i-col span="10" style="display:flex;">
                        <Radio label="指定日期">
                        </Radio>
                        <span style="font-weight:normal">
                          <DatePicker :editable="false" :disabled="disabledPlan.appointedDayDisabled" placeholder="指定日期"
                            v-model="disabledPlan.appointedDay" @on-change="dateValue3"></DatePicker>
                        </span>
                      </i-col>
                    </RadioGroup>
                  </FormItem>
                </Row>
              </Div>
            </i-col>
            <i-col span="9">
              <Div class="supervise-content">
                <div class="planTime">工作方式:</div>
                <Select v-model="disabledPlan.workType" clearable>
                  <Option v-for="item in workType" :key="item.key" :value="item.key">{{ item.value }}</Option>
                </Select>
              </Div>
            </i-col>
            <i-col span="1">
              <div class="confirm">
                <FormItem>
                  <Button type="primary" @click="PlanSubmit()" :loading="planSubmit">
                    确
                    <br />定
                  </Button>
                </FormItem>
              </div>
            </i-col>
          </Row>
        </Form>
      </Div>
      <Button :type="onWorkButton" class="onWork" @click="onWorkQuery">在职单</Button>
      <Button :type="orphanButton" class="onWork" @click="orphanQuery">孤儿单</Button>
      <Table :columns="disabledColumns" :data="disabledData" style="margin-top:20px"
        @on-selection-change="selectionChange">
        <template slot-scope="{row}" slot="contstatename">
          <span v-if="row.contstatename == '失效中'" style="color: rgba(255, 141, 26, 1);">
            <span class="circle" style="background-color: rgba(255, 141, 26, 1);margin-right:5px"></span>
            {{ row.contstatename }}
          </span>
          <span v-if="row.contstatename == '终止'" style="color: rgba(166, 166, 166, 1);">
            <span class="circle" style="background-color: rgba(166, 166, 166, 1);margin-right:5px"></span>
            {{ row.contstatename }}
          </span>
        </template>
      </Table>
      <Page :total="total" show-sizer show-total style="text-align:right;margin-top:20px" @on-change="pageChange"
        @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeOptions" :current="pageIndex" :page-size="pageSize"
        transfer></Page>
    </Card>
    <div class="contain" ref="mybox">
      <canvas id="myCanvas" width="200" height="100" ref="myCanvas" style="position: absolute;"></canvas>
    </div>
  </div>
</template>

<script>
import util from "../../../util/util";
import { drawSign } from '../../../util/drawSign'
export default {
  props: {
    payWayList: {
      type: Array
    }
  },
  data() {
    const validatePremium = (rule, value, callback) => {
      if (value) {
        let reg = /^[0-9][0-9]*$/;
        let reg1 = /^(([0-9]{1}\d*)|(0{1}))(\.\d{1})$/;
        let reg2 = /^(([0-9]{1}\d*)|(0{1}))(\.\d{2})$/;
        if (reg.test(value)) {
          callback();
        } else if (reg1.test(value)) {
          callback();
        } else if (reg2.test(value)) {
          callback();
        } else {
          callback(new Error("请输入两位小数"));
        }
      } else {
        callback();
      }
      callback();
    };
    return {
      disabledForm: {
        policyNo: "",
        organiztion: "",
        clerkName: "",
        applicantName: "",
        premiumMin: "",
        premiumMax: "",
        payableDayRange: ["", ""],
        disabledDayRange: ["", ""],
        disabledDayMin: "",
        disabledDayMax: "",
        postaladdress: "",
        payWay: '',
      },
      disabledPlan: {
        planTime: "",
        workType: "",
        afterDayDisabled: "true",
        afterDay: "",
        appointedDayDisabled: "true",
        appointedDay: "",
        finalPlanTime: ""
      },
      organiztions: [],
      disabledData: [],
      workType: [],
      // 表格数据
      disabledColumns: [
        {
          type: "selection",
          align: "center",
          fixed: "left",
          width: 60
        },
        {
          title: "保单号",
          key: "contno",
          fixed: "left",
          width: 180
        },
        {
          title: "投保人",
          align: "center",
          key: "appntname",
          // sortable: true,
          width: 130
        },
        {
          title: "应交日",
          align: "center",
          key: "paytodate",
          // sortable: true,
          width: 140
        },
        {
          title: "已交次数",
          align: "center",
          key: "count",
          width: 120
        },
        {
          title: "应收保费(元)",
          align: "center",
          key: "sumduepaymoney",
          // sortable: true,
          width: 140
        },
        {
          title: "主险",
          key: "mainRisks",
          width: 350
        },
        {
          title: "失效日",
          align: "center",
          key: "disabledDay",
          // sortable: true,
          width: 140
        },
        {
          title: "保单状态",
          key: "contstatename",
          align: "center",
          width: "150",
          slot: "contstatename"
        },
        {
          title: "失效天数",
          align: "center",
          key: "invalidvalue",
          minWidth: 110
        },
        {
          title: "业务员",
          align: "center",
          key: "clerk",
          fixed: "right",
          width: 190
        }
      ],
      rules: {
        premiumMin: [{ validator: validatePremium, trigger: "blur" }],
        premiumMax: [{ validator: validatePremium, trigger: "blur" }]
      },
      total: 0,
      pageSizeOptions: [5, 10, 15, 20],
      pageIndex: 1,
      pageSize: 10,
      onWorkButton: "default",
      orphanButton: "default",
      onWorkData: [],
      orphanData: [],
      otherData: [],
      querySubmit: false,
      planSubmit: false,
      selectionData: [],
      pageObj: ""
    };
  },
  methods: {
    // 保单查询
    handleSubmit(params) {
      this.$refs.disabledForm.validate(valid => {
        if (valid) {
          let status = null;
          if (params) {
            if (params == "在职单") {
              status = 0;
            }
            if (params == "孤儿单") {
              status = 1;
            }
          } else {
            this.querySubmit = true;
            this.onWorkButton = "default";
            this.orphanButton = "default";
          }
          this.pageIndex = 1;
          this.pageSize = 10;
          let obj = {
            index: this.pageIndex,
            pageSize: this.pageSize,
            initflag: 0,
            selecttype: 2,
            contno: this.disabledForm.policyNo
              ? this.disabledForm.policyNo
              : null,
            agentcom: this.disabledForm.organiztion
              ? this.disabledForm.organiztion[this.disabledForm.organiztion.length - 1]
              : null,
            agentname: this.disabledForm.clerkName
              ? this.disabledForm.clerkName
              : null,
            appntname: this.disabledForm.applicantName
              ? this.disabledForm.applicantName
              : null,
            rangeminpaytodate: util.dateToISOString(
              this.disabledForm.payableDayRange[0]
            ),
            rangemaxpaytodate: util.dateToISOString(
              this.disabledForm.payableDayRange[1]
            ),
            rangemininvaliddate: util.dateToISOString(
              this.disabledForm.disabledDayRange[0]
            ),
            rangemaxinvaliddate: util.dateToISOString(
              this.disabledForm.disabledDayRange[1]
            ),
            rangeminprem: this.disabledForm.premiumMin
              ? this.disabledForm.premiumMin
              : null,
            rangemaxprem: this.disabledForm.premiumMax
              ? this.disabledForm.premiumMax
              : null,
            rangemininvalidvalue: this.disabledForm.disabledDayMin
              ? this.disabledForm.disabledDayMin
              : null,
            rangemaxinvalidvalue: this.disabledForm.disabledDayMax
              ? this.disabledForm.disabledDayMax
              : null,
            superviseflag: status,
            postaladdress: this.disabledForm.postaladdress
              ? this.disabledForm.postaladdress
              : null,
            payintv: this.disabledForm.payWay ? this.disabledForm.payWay : null,//交费方式
          };
          this.pageObj = obj;
          this.api.getlist(obj).then(res => {
            res.data.ipage = {
              "records": [
                {
                  "contno": "0000584422601818",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "111309",
                  "appntname": "年翠丝",
                  "appntid": "0000952073",
                  "paytodate": "2034-03-23 00:00:00",
                  "payyear": "12",
                  "payyears": "20",
                  "sumduepaymoney": "0.00",
                  "riskname": "****人寿福鑫年年终身年金保险",
                  "agentname": "赵天天",
                  "invaliddate": "2033-05-23 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "2",
                  "invalidvalue": "-3596",
                  "contstatename": "终止"
                },
                {
                  "contno": "0005371523411888",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "511102",
                  "appntname": "化一",
                  "appntid": "0001055815",
                  "paytodate": "2024-05-30 00:00:00",
                  "payyear": "1",
                  "payyears": "3",
                  "sumduepaymoney": "1963.55",
                  "riskname": "盛世传承终身寿险",
                  "agentname": "徐钰",
                  "invaliddate": "2024-07-30 00:00:00",
                  "agentcode": "61004415",
                  "contstate": "2",
                  "invalidvalue": "-377",
                  "contstatename": "终止"
                },
                {
                  "contno": "0004525521501888",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "111506",
                  "appntname": "周枫停售附加险",
                  "appntid": "0000875575",
                  "paytodate": "2024-03-09 00:00:00",
                  "payyear": "3",
                  "payyears": "5",
                  "sumduepaymoney": "13284.00",
                  "riskname": "康佑人生A款重大疾病保险",
                  "agentname": "陈sj",
                  "invaliddate": "2024-05-09 00:00:00",
                  "agentcode": "61003902",
                  "contstate": "1",
                  "invalidvalue": "-295",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0004537816191888",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "111506",
                  "appntname": "林森",
                  "appntid": "0000881134",
                  "paytodate": "2024-03-03 00:00:00",
                  "payyear": "8",
                  "payyears": "15",
                  "sumduepaymoney": "1332.00",
                  "riskname": "康佑人生A款重大疾病保险",
                  "agentname": "朱宇晴",
                  "invaliddate": "2024-05-03 00:00:00",
                  "agentcode": "61003220",
                  "contstate": "1",
                  "invalidvalue": "-289",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0002033122371813",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "511102",
                  "appntname": "徐蓉",
                  "appntid": "0000873506",
                  "paytodate": "2023-04-02 00:00:00",
                  "payyear": "1",
                  "payyears": "5",
                  "sumduepaymoney": "6000.00",
                  "riskname": "盛世传承终身寿险",
                  "agentname": "赵天天",
                  "invaliddate": "2023-06-02 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "1",
                  "invalidvalue": "47",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0000668122661818",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "511102",
                  "appntname": "刘冬冬",
                  "appntid": "0001040456",
                  "paytodate": "2023-03-20 00:00:00",
                  "payyear": "1",
                  "payyears": "3",
                  "sumduepaymoney": "29990000.00",
                  "riskname": "盛世传承终身寿险",
                  "agentname": "赵天天",
                  "invaliddate": "2023-05-20 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "1",
                  "invalidvalue": "60",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0000667722021818",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "511102",
                  "appntname": "陈春一",
                  "appntid": "0001040306",
                  "paytodate": "2023-03-02 00:00:00",
                  "payyear": "1",
                  "payyears": "3",
                  "sumduepaymoney": "30000000.00",
                  "riskname": "盛世传承终身寿险",
                  "agentname": "赵天天",
                  "invaliddate": "2023-05-02 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "1",
                  "invalidvalue": "78",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0004925922981813",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "511102",
                  "appntname": "体验测试",
                  "appntid": "0001037381",
                  "paytodate": "2023-02-11 00:00:00",
                  "payyear": "1",
                  "payyears": "10",
                  "sumduepaymoney": "100000.00",
                  "riskname": "盛世传承终身寿险",
                  "agentname": "赵天天",
                  "invaliddate": "2023-04-13 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "1",
                  "invalidvalue": "97",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0004926022171813",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "511102",
                  "appntname": "体验测试",
                  "appntid": "0001037381",
                  "paytodate": "2023-02-11 00:00:00",
                  "payyear": "1",
                  "payyears": "10",
                  "sumduepaymoney": "100000.00",
                  "riskname": "盛世传承终身寿险",
                  "agentname": "赵天天",
                  "invaliddate": "2023-04-13 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "1",
                  "invalidvalue": "97",
                  "contstatename": "失效中"
                },
                {
                  "contno": "0004956323851813",
                  "payintvname": "年交",
                  "payintv": "12",
                  "riskcode": "211206",
                  "appntname": "清保",
                  "appntid": "0001039521",
                  "paytodate": "2023-01-11 00:00:00",
                  "payyear": "1",
                  "payyears": "5",
                  "sumduepaymoney": "70000.00",
                  "riskname": "****人寿平安如意两全保险",
                  "agentname": "赵天天",
                  "invaliddate": "2023-03-13 00:00:00",
                  "agentcode": "8601010114",
                  "contstate": "1",
                  "invalidvalue": "128",
                  "contstatename": "失效中"
                }
              ],
              "total": "10",
              "size": "10",
              "current": "1",
              "orders": [],
              "searchCount": true,
              "pages": "1"
            }
            if (res.code == 200 && res.data != null) {
              this.querySubmit = false;
              if (res.data.ipage && res.data.ipage.total > 0) {
                if (params != 999) {
                  this.$Message.info("查询成功");
                }
                this.total = res.data.ipage.total;
                this.disabledData = res.data.ipage.records;
                this.disabledData.forEach(element => {
                  if (
                    element.payyear &&
                    element.payyears &&
                    element.payintvname
                  ) {
                    element.count =
                      element.payyear +
                      "/" +
                      element.payyears +
                      element.payintvname;
                  }
                  if (element.paytodate) {
                    element.paytodate = element.paytodate.substr(0, 10);
                  }
                  if (element.riskcode && element.riskname) {
                    element.mainRisks =
                      element.riskname + "-" + element.riskcode;
                  }
                  if (element.agentcode && element.agentname) {
                    element.clerk = element.agentname + "-" + element.agentcode;
                  }
                  if (element.invaliddate) {
                    element.disabledDay = element.invaliddate.substr(0, 10);
                  }
                });
                // this.organiztions = res.data.baseMapForPlanList.ldcoms;
                this.workType = res.data.baseMapForPlanList.worktype;
              } else {
                this.total = 0;
                this.disabledData = [];
                if (params != 999) {
                  this.$Message.info("查询数据为空");
                }
              }
            } else {
              this.querySubmit = false;
              this.total = 0;
              this.disabledData = [];
              if (params != 999) {
                this.$Message.info(res.msg);
              }
            }
          });
        } else {
          this.$Message.error("信息填写有误");
        }
      });
    },

    // 分页查询
    pageSubmit() {
      this.pageObj.index = this.pageIndex;
      this.pageObj.pageSize = this.pageSize;
      this.api.getlist(this.pageObj).then(res => {
        if (res.code == 200 && res.data != null) {
          this.querySubmit = false;
          // this.organiztions = res.data.baseMapForPlanList.ldcoms;
          this.workType = res.data.baseMapForPlanList.worktype;
          if (res.data.ipage && res.data.ipage.total > 0) {
            this.total = res.data.ipage.total;
            this.disabledData = res.data.ipage.records;
            this.disabledData.forEach(element => {
              if (element.payyear && element.payyears && element.payintvname) {
                element.count =
                  element.payyear +
                  "/" +
                  element.payyears +
                  element.payintvname;
              }
              if (element.paytodate) {
                element.paytodate = element.paytodate.substr(0, 10);
              }
              if (element.riskcode && element.riskname) {
                element.mainRisks = element.riskname + "-" + element.riskcode;
              }
              if (element.agentcode && element.agentname) {
                element.clerk = element.agentname + "-" + element.agentcode;
              }
              if (element.invaliddate) {
                element.disabledDay = element.invaliddate.substr(0, 10);
              }
            });
          } else {
            this.total = 0;
            this.disabledData = [];
            this.$Message.info("查询数据为空");
          }
        } else {
          this.querySubmit = false;
          this.total = 0;
          this.disabledData = [];
          this.$Message.info(res.msg);
        }
      });
    },

    // 在职单查询
    onWorkQuery() {
      if (this.disabledData.length > 0) {
        this.onWorkButton = "primary";
        this.orphanButton = "default";
        this.handleSubmit("在职单");
      } else {
        this.$Message.info("请先查询出数据");
        return;
      }
    },

    // 孤儿单查询
    orphanQuery() {
      if (this.disabledData.length > 0) {
        this.onWorkButton = "default";
        this.orphanButton = "primary";
        this.handleSubmit("孤儿单");
      } else {
        this.$Message.info("请先查询出数据");
        return;
      }
    },

    // 重置表单
    handleReset() {
      this.$refs.disabledForm.resetFields();
      this.disabledForm = {
        policyNo: "",
        organiztion: "",
        clerkName: "",
        applicantName: "",
        premiumMin: "",
        premiumMax: "",
        payableDayRange: ["", ""],
        disabledDayRange: ["", ""],
        disabledDayMin: "",
        disabledDayMax: "",
        postaladdress: "",
        payWay: '',
      };
    },

    getOrganization() {
      this.api.getagentList({ branchtype: '05' }).then(res => {
        if (res.code == 200 && res.data != null) {
          let arr = []
          arr = res.data
          arr.forEach(one => {
            one.value = one.comcode
            one.label = one.comcode + '-' + one.name
            one.children = one.chilDren || []
            if (one.children && one.children.length > 0) {
              one.chilDren.forEach(two => {
                two.value = two.comcode
                two.label = two.comcode + '-' + two.name
                two.children = two.chilDren || []
                if (two.children && two.children.length > 0) {
                  two.children.forEach(three => {
                    three.value = three.comcode
                    three.label = three.comcode + '-' + three.name
                    three.children = three.chilDren || []
                    if (three.children && three.children.length > 0) {
                      three.children.forEach(four => {
                        four.value = four.comcode
                        four.label = four.comcode + '-' + four.name
                        four.children = four.chilDren || []
                      })
                    }
                  })
                }
              })
            }
          })
          console.log(arr);
          this.organiztions = arr
        } else {
          this.organiztions = [];
        }
      });
    },

    // 表格多选获取数据
    selectionChange(selection) {
      this.selectionData = selection;
    },

    // 单选按钮选择，其他置灰
    PlanTypeChange(status) {
      if (status == "失效日后") {
        this.disabledPlan.afterDayDisabled = false;
        this.disabledPlan.appointedDayDisabled = true;
        this.disabledPlan.finalPlanTime = this.disabledPlan.afterDay;
      }
      if (status == "指定日期") {
        this.disabledPlan.afterDayDisabled = true;
        this.disabledPlan.appointedDayDisabled = false;
        this.disabledPlan.finalPlanTime = this.disabledPlan.appointedDay;
      }
    },

    // 获取单选按钮中的输入框的值
    dateValue2() {
      this.disabledPlan.finalPlanTime = this.disabledPlan.afterDay;
    },
    dateValue3() {
      this.disabledPlan.finalPlanTime = this.disabledPlan.appointedDay;
    },

    // 计划提交
    PlanSubmit() {
      this.planSubmit = true;
      if (this.selectionData.length > 0) {
        if (this.disabledPlan.finalPlanTime && this.disabledPlan.workType) {
          let selectionDataObj = JSON.parse(JSON.stringify(this.selectionData));
          // 添加数据
          selectionDataObj.forEach(element => {
            element.plantype = 2;
            element.worktype = this.disabledPlan.workType;
            if (element.sumduepaymoney) {
              element.sumprem = element.sumduepaymoney;
            } else {
              element.sumprem = '0';
            }
            // 将计划时间转化为应交日前、后的天数
            if (
              element.disabledDay &&
              this.disabledPlan.planTime !== "指定日期"
            ) {
              element.datevlue = this.disabledPlan.finalPlanTime;
              let oldTime = new Date(element.disabledDay).getTime();
              let diffTime =
                this.disabledPlan.finalPlanTime * 24 * 60 * 60 * 1000;
              element.appointeddate = new Date(oldTime + diffTime);
              element.plandatetype = 3;
            } else {
              element.plandatetype = 2;
              element.appointeddate = util.dateToISOString(
                this.disabledPlan.finalPlanTime
              );
            }
          });
          this.$emit("resetBadge");
          this.planSubmit = false;
          this.$Message.success('提交成功');
          // 循环提交
          // let index = 0;
          // selectionDataObj.forEach(element => {
          //   this.api.saveplan(element).then(res => {
          //     if (res.code == 200 && res.data != null) {
          //       index++;
          //       if (index == selectionDataObj.length) {
          //         this.$emit("resetBadge");
          //         this.handleSubmit(1);
          //         this.planSubmit = false;
          //         this.$Message.success(res.msg);
          //       }
          //     } else {
          //       index++;
          //       this.$Message.info(res.msg);
          //       if (index == selectionDataObj.length) {
          //         this.$emit("resetBadge");
          //         this.handleSubmit(1);
          //         this.planSubmit = false;
          //       }
          //     }
          //   });
          // });
        } else {
          this.planSubmit = false;
          this.$Message.info("计划时间/计划方式未录入，不可进行此操作");
          return false;
        }
      } else {
        this.planSubmit = false;
        this.$Message.info("未选择保单，不可进行此操作");
        return false;
      }
    },

    // 分页设置
    pageChange(pageIndex) {
      this.pageIndex = pageIndex;
      this.pageSubmit();
    },
    pageSizeChange(pageSize) {
      this.pageSize = pageSize;
      this.pageSubmit();
    },

    // 转化为两位小数
    decimalConversion(value) {
      let reg = /^[0-9][0-9]*$/;
      let reg1 = /^(([0-9]{1}\d*)|(0{1}))(\.\d{1})$/;
      let reg2 = /^(([0-9]{1}\d*)|(0{1}))(\.\d{2})$/;
      if (value) {
        if (reg.test(value)) {
          this.disabledForm.premiumMin = value + ".00";
        } else if (reg1.test(value)) {
          this.disabledForm.premiumMin = value + "0";
        } else if (reg2.test(value)) {
        } else {
          this.$refs.disabledForm.validateField("premiumMin");
        }
      } else {
        this.disabledForm.premiumMin = null;
      }
    },

    decimalConversion2(value) {
      let reg = /^[0-9][0-9]*$/;
      let reg1 = /^(([0-9]{1}\d*)|(0{1}))(\.\d{1})$/;
      let reg2 = /^(([0-9]{1}\d*)|(0{1}))(\.\d{2})$/;
      if (value) {
        if (reg.test(value)) {
          this.disabledForm.premiumMax = value + ".00";
        } else if (reg1.test(value)) {
          this.disabledForm.premiumMax = value + "0";
        } else if (reg2.test(value)) {
        } else {
          this.$refs.disabledForm.validateField("premiumMax");
        }
      } else {
        this.disabledForm.premiumMax = null;
      }
    },
    draw(ele, loginUser, loginTime) {
      let imageUrl = drawSign(ele, loginUser, loginTime)
      document.getElementsByClassName("ivu-table-fixed-body")[3].style.background = 'url(' + imageUrl + ') left top repeat'
      document.getElementsByClassName("ivu-table-fixed-body")[3].classList.add("add-background")

      document.getElementsByClassName("ivu-table-fixed-body")[4].style.background = 'url(' + imageUrl + ') left top repeat'
      document.getElementsByClassName("ivu-table-fixed-body")[4].classList.add("add-background")

      document.getElementsByClassName("ivu-table-body")[2].style.background = 'url(' + imageUrl + ') left top repeat'
      document.getElementsByClassName("ivu-table-body")[2].classList.add("add-background")

    },
    //交费方式
    changePayWay(value) {
      console.log(value, '交费方式', this.disabledForm.payWay);
    },
  },
  mounted() {
    this.handleSubmit(999);
    this.getOrganization()
    let loginUser = sessionStorage.getItem("name");
    let loginTime =
      new Date().getFullYear() +
      "/" +
      (new Date().getMonth() + 1) +
      "/" +
      (new Date().getDate());
    // drawSign(this.$refs.myCanvas,loginUser,loginTime)
    this.draw(this.$refs.myCanvas, loginUser, loginTime)
  },
  beforeDestroy() {
    this.disabledData = [];
    this.disabledForm = null
    this.disabledPlan = null
    this.organiztions = null
    this.disabledData = null
    this.workType = null
    this.disabledColumns = null
    this.rules = null
    this.total = null
    this.pageSizeOptions = null
    this.pageIndex = null
    this.pageSize = null
    this.onWorkButton = null
    this.orphanButton = null
    this.onWorkData = null
    this.orphanData = null
    this.otherData = null
    this.querySubmit = null
    this.planSubmit = null
    this.selectionData = null
    this.pageObj = null
  }
};
</script>    

<style lang="less">
@import "./index.less";
</style>